﻿using furion.blog.Application.Contracts;
using furion.blog.Domain.Shared.Attribute;
using furion.blog.Utils;
using Furion.DynamicApiController;
using Microsoft.AspNetCore.Mvc;

namespace furion.blog.Web.Entry.Api
{
    /// <summary>
    /// 微信请求日志相关接口
    /// </summary>
    [ApiDescriptionSettings(Groups = new string[] { "WxRequestLogApi" })]
    [Route("api/wxRequestLog")]
    public class WxRequestLogApiController : IDynamicApiController
    {
        private readonly IWxRequestLogService _wxRequestLogService;

        public WxRequestLogApiController(IWxRequestLogService wxRequestLogService) {
            this._wxRequestLogService = wxRequestLogService;
        }

        [ActionAttribute(Name = "请求日志分页接口", Desc = "请求日志分页数据")]
        [HttpGet, Route("list")]
        public async Task<IActionResult> list(
          [FromQuery(Name = "page")] int pageIndex,
          [FromQuery(Name = "limit")] int pageSize,
          [FromQuery(Name = "searchContent")] string searchContent = "",
          [FromQuery(Name = "date")] string date = "",
          [FromQuery(Name = "requestMethod")] string requestMethod = "",
          [FromQuery(Name = "api")] string api = ""
          )
        {
            var ret = await this._wxRequestLogService.List(new Domain.Query.WxRequestLog.WxRequestLogListQuery { 
              PageIndex = pageIndex,
              PageSize = pageSize,
              SearchContent = searchContent,
              Date = date,
              RequestMethod = requestMethod,
              Api = api,
            });
            return new OkObjectResult(ResultUtil.Success(ret));
        }

    }
}
